import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

// // 测试接口
// export const getDevice = (data) => {
//   return http.request('get', baseUrlApi('/device/info'), { data });
// };

// // 测试接口 params传参
// export const getTest = (params) => {
//   return http.request("get", baseUrlApi('/menu/role-menusandchecked'), { params });
// };
// 从数据湖获取文件列表
export const fetchFileListFromDataLake = (directory = '/') => {
  return http.request("get", "http://10.8.58.1:8400/integration/getFileList", {
    params: {
      directory: directory // 传递目录参数，默认为根目录
    }
  });
};

// 将被监控的数据入湖
export const uploadMonitorData = jsonStr => {
  return http.request("post", "http://10.8.58.1:8400/integration/postJsonStr", {
    data: {
      dst: "resourceMonitorKeti1", // 表名
      mode: "overwrite", // 有append和overwrite模式
      json: jsonStr
    }
  });
};

// 获取设备产品服务列表
export const getDeviceList = () => {
  return http.request("get", baseUrlApi("/device/show/1"));
};

// 添加协议配置
export const addDevice = data => {
  return http.request("post", baseUrlApi("/device/add"), { data });
};

// 删除配置协议
export const deleteDeviceInfo = data => {
  return http.request("post", baseUrlApi("/device/delete"), { data });
};

// 获取资源类型列表
export const getDeviceData = params => {
  return http.request(
    "get",
    baseUrlApi("/device/shows/") + params.deviceType + "/" + params.deviceName
  );
};

// 添加设备产品服务
export const addDeviceList = data => {
  return http.request("post", baseUrlApi("/device/edit"), { data });
};

// 修改
export const modifyDeviceList = data => {
  return http.request("post", baseUrlApi("/device/save"), { data });
};

// 采集设置
export const collectSet = data => {
  return http.request("post", baseUrlApi("/device/save"), { data });
};

// 新的接口
// 配置指令
export const deviceConfig = params => {
  return http.get(baseUrlApi("/device/config"), { params });
};
// 编译指令
export const deviceCompile = params => {
  return http.get(baseUrlApi("/device/compile"), { params });
};
// 下发指令
export const deviceSend = params => {
  return http.get(baseUrlApi("/device/send"), { params });
};
// 采集指令
export const deviceCollection = params => {
  return http.get(baseUrlApi("/device/collection"), { params });
};
